﻿
using Beway.ValueAdded.Model;
using Beway.ValueAdded.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Beway.ValueAdded.Admin.Controllers
{
    public class ReUserFinanceController:BaseController
    {
        ReUserFinanceSvc rufSvc = SingletonProvider<ReUserFinanceSvc>.Instance;

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult PagedList(int? page, int? rows, int? userId)
        {
            int ListCount = 0;
            int adminId = 0;
            if (CurrentRole == ManagerRoleType.MerchantAdmin)
            {
                adminId = CurrentAdmin.AdminID;
            }
            var d = rufSvc.PagedList(page ?? 0, rows ?? 0, userId ?? 0, adminId, out ListCount);

            Dictionary<string, object> json = new Dictionary<string, object>();
            json.Add("total", ListCount);
            json.Add("rows", d);
            return Json(json, JsonRequestBehavior.AllowGet);
        }



        [HttpPost]
        public ActionResult Add(ReUserFinance Model)
        {
            int Result = 0;
            //if (CurrentRole == ManagerRoleType.SystemAdmin)
            //{
                Model.AdminId = CurrentAdmin.AdminID;//当前登录管理员的Id
                Model.AddTime = System.DateTime.Now;

                if (rufSvc.Add(Model))
                {
                    Result = 1;
                }
            //}

            return Content(Result.ToString());
        }         
    }
}